package com.dongzili.disruptor.controller;

import com.dongzili.common.disruptor.entity.MessageEvent;
import com.dongzili.common.disruptor.enums.MessageType;
import com.dongzili.common.disruptor.service.DisruptorMqService;
import com.dongzili.common.vo.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("disruptor")
public class MessageController {

    @Resource
    private DisruptorMqService<String> disruptorMqService;

    @GetMapping("send")
    public R<String> send(String message) {

        disruptorMqService.sendMq(MessageType.Message, new MessageEvent<String>().setData(message));
        log.info("消息队列已发送完毕");
        return R.success();
    }
}
